import os
import sys

def walk_dir(dir,fileinfo,topdown=True):
    for root, dirs, files in os.walk(dir, topdown):
        for name in files:
            ext = os.path.splitext(os.path.join(name) )[1].lower()
            if ext == '.cpp' or ext == '.h' or ext == '.c':
                print( os.path.join(name))
                os.system( 'indent ' + os.path.join(root, name) )
                fileinfo.write( '  ' + os.path.join(root, name) + '\n')
#
#        for name in dirs:
#            print( os.path.join(name))
#            fileinfo.write('  ' + os.path.join(root,name) + '\n')

dir = raw_input('please input the path:')
fileinfo = open('list.txt','w')
walk_dir(dir,fileinfo)
